package com.cyan.note.mapper;

import com.cyan.note.entity.ShopSetting;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;

/**
 * 店铺设置Mapper接口
 * 
 * @author ZhangzhenYu
 * @since 2025-01-15
 */
@Mapper
public interface ShopSettingMapper {

    /**
     * 根据ID查询设置
     */
    ShopSetting selectById(@Param("id") Long id);

    /**
     * 插入设置
     */
    int insert(ShopSetting shopSetting);

    /**
     * 更新设置
     */
    int updateById(ShopSetting shopSetting);

    /**
     * 删除设置
     */
    int deleteById(@Param("id") Long id);

    /**
     * 根据店铺ID和分类查询设置
     */
    List<ShopSetting> selectByShopAndCategory(@Param("shopId") Long shopId, @Param("category") String category);

    /**
     * 根据店铺ID查询所有设置（Map格式）
     */
    Map<String, String> selectAllSettingsAsMap(@Param("shopId") Long shopId);

    /**
     * 根据设置键查询值
     */
    String selectSettingValue(@Param("shopId") Long shopId, @Param("settingKey") String settingKey);

    /**
     * 批量更新或插入设置
     */
    int batchUpsertSettings(@Param("shopId") Long shopId, @Param("settings") List<ShopSetting> settings);

    /**
     * 删除店铺的某个分类的设置
     */
    int deleteByShopAndCategory(@Param("shopId") Long shopId, @Param("category") String category);

    /**
     * 根据店铺ID和设置键查询设置
     */
    ShopSetting selectByShopAndKey(@Param("shopId") Long shopId, @Param("settingKey") String settingKey);
}